import { encode, decode } from 'js-base64'
import { tokenTo } from './tokenOper'

const multiparty = require('multiparty')
/* const form = new multiparty.Form()
form.uploadDir = './'
form.keepExtensions = true */
export const analysis = req =>{
  const type = req.headers['content-type']
  const token = req.headers['src-token']
 /*  if(/multipart\/form-data\;/.test(type)){
    return new Promise((success,error)=>{
      form.parse(req, function(err, fields, files) {
        if(err) error()
        // console.log({fields,files})
        success({
          data:Object.assign({token},fields),
          files
        })
      })
    })
  }else{ */
    const data = req.body
    const params = req.query
    const file = req.file
    return {
      params,
      data,
      token,
      file,
    }
  // }
}